/*
 * Copyright (c) 2019 Author: Fancyears Milos Malvis @1243093366@qq.com
 * ALL COPYRIGHT REVERSED.
 */

package com.fancyears.service.i.encryption;

import org.bouncycastle.asn1.ASN1Primitive;

import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.security.AlgorithmParameters;
import java.security.KeyPair;
import java.security.NoSuchAlgorithmException;
import java.util.Map;

/**
 * @Author: Fancyears Milos Malvis
 * @Date: Created in  2019/6/27 10:52
 * @Modified By:
 */
public interface RSAService {

    Map<String, String> getSession(HttpSession clientSession) throws NoSuchAlgorithmException, IOException;


    Map<String, Object> loginByEncrypt(Map<String, String> params, HttpSession clientSession);

    /**
     * 私钥解密
     *
     * @param encode
     * @param privateKey
     * @return
     * @throws Exception
     */
    String decrypt(String encode, String privateKey) throws Exception;

    /**
     * 获取到公钥
     * @param keyPair
     * @return
     * @throws IOException
     */
    String getPublicKey(KeyPair keyPair) throws IOException;

    /**
     *  获取到私钥
     * @param keyPair
     * @return
     * @throws IOException
     */
    String getPrivateKey(KeyPair keyPair) throws IOException;

    /**
     * 生成钥匙对
     * @return
     * @throws NoSuchAlgorithmException
     */
    KeyPair getKeyPair() throws NoSuchAlgorithmException;

    /**
     * 更新密码
     * @param params
     * @param session
     * @return
     */
    Map<String,Object> updatePassword(Map<String,String> params, HttpSession session);
}
